
#pragma once

#include <TCHAR.H>
#include <windows.h>
#include <string>

class __declspec(novtable) GLresource
{
public:
	std::string m_name;

	GLresource():m_nRefCount(0){
	}

	virtual ~GLresource(){
		Release();
	}

	virtual void Destroy() = 0;

	void AddRef(){ 
		InterlockedIncrement(&m_nRefCount); 
	}

	LONG GetRefCount(){
		return m_nRefCount;
	}

	void Release(){ 
		if( m_nRefCount > 0){
			InterlockedDecrement(&m_nRefCount);
			if(m_nRefCount == 0)
				Destroy();
		}
	}
	
protected:
	LONG m_nRefCount;

};